<!-- script代码，如果需要引用js文件，请使用与HTML中相同的方式。 -->
<script type="text/javascript">
function check_form(thiswins,items)
{
	/* added by cyril on 2008-08-14 for td:8521 */
	var isconn = false;
	try {
		var xmlhttp;
	    if (window.XMLHttpRequest) {
	    	xmlhttp = new XMLHttpRequest();
	    }  
	    else if (window.ActiveXObject) {
	    	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");  
	    }
	    var URL = "/systeminfo/CheckConn.jsp?userid=1&time="+new Date()+"&f_weaver_belongto_userid=1&f_weaver_belongto_usertype=0";
	    xmlhttp.open("GET",URL, false);
	    xmlhttp.send(null);
	    var result = xmlhttp.status;
	    if(result==200) {
		    isconn = true;
	    	var response_flag = xmlhttp.responseText;
	    	if(response_flag!='0') {
	    		var flag_msg = '';
	    		if(response_flag=='1') {
	    			var diag = new Dialog();
					diag.Width = 300;
					diag.Height = 180;
					diag.ShowCloseButton=false;
					diag.Title = "网页超时提醒";
					//diag.InvokeElementId="pageOverlay"
					diag.URL = "/wui/theme/ecology7/page/loginSmall.jsp?username=sysadmin";
					diag.show();
			        return false;
	    		}
	    		else if(response_flag=='2') {
	    			flag_msg = '网络故障或其它原因导致您连接不上服务器，请复制下重要信息稍候再提交！';
	    		}
	    		//主从帐户特殊处理 by alan for TD10156
	    		if(response_flag=='3') {
	    			flag_msg = '提交信息失败,该页面非当前帐号打开,请刷新页面后再提交!';
	   
	    			return false;
	    		}
	    		flag_msg += '\r\n\r\n按【确定】继续,按【取消】停留在本页!';
	        	//alert(xmlhttp.responseText);
	        	return confirm(flag_msg);
	        }
	    }
	    xmlhttp = null;

	  	//检查多行文本框 oracle下检查HTML不能超过4000个字符
	    
	}
	catch(e) {
		return check_conn();
	}
	if(!isconn)
		return check_conn();
    /* end by cyril on 2008-08-14 for td:8521 */
	
	thiswin = thiswins
	items = ","+items + ",";
	
	var tempfieldvlaue1 = "";
	try{
		tempfieldvlaue1 = document.getElementById("htmlfieldids").value;
	}catch (e) {
	}

	for(i=1;i<=thiswin.length;i++){
		tmpname = thiswin.elements[i-1].name;
		tmpvalue = thiswin.elements[i-1].value;
	    if(tmpvalue==null){
	        continue;
	    }

		if(tmpname!="" && items.indexOf(","+tmpname+",")!=-1){		
			var __fieldhtmltype = jQuery("input[name=" + tmpname + "]").attr("__fieldhtmltype");
		    if (__fieldhtmltype == '9') {
		        continue;
		    }
		
			var href = location.href;
			if(href && href.indexOf("Ext.jsp")!=-1){
				window.__oriAlert__ = true;
			}
			if(tempfieldvlaue1.indexOf(tmpname+";") == -1){
				while(tmpvalue.indexOf(" ") >= 0){
					tmpvalue = tmpvalue.replace(" ", "");
				}
				while(tmpvalue.indexOf("\r\n") >= 0){
					tmpvalue = tmpvalue.replace("\r\n", "");
				}

				if(tmpvalue == ""){
					if(thiswin.elements[i-1].getAttribute("temptitle")!=null && thiswin.elements[i-1].getAttribute("temptitle")!=""){
						if(window.__oriAlert__){
							window.top.Dialog.alert("\""+thiswin.elements[i-1].getAttribute("temptitle")+"\""+"未填写");
						}else{
							var tempElement = thiswin.elements[i-1];
							//ueditor必填验证
							if (checkueditorContent(tempElement)) {
								continue;
							}
							
							window.top.Dialog.alert("&quot;"+thiswin.elements[i-1].getAttribute("temptitle")+"&quot;"+"未填写", function () {
						    formElementFocus(tempElement);						
							});
						}
						return false;
					}else{
						if(window.__oriAlert__){
							try{
								window.top.Dialog.alert("必要信息不完整，红色叹号为必填项！");
							}catch(e){
								Dialog.alert("必要信息不完整，红色叹号为必填项！");
							}
						}else{
							try{
								window.top.Dialog.alert("必要信息不完整，红色叹号为必填项！");
							}catch(e){
								Dialog.alert("必要信息不完整，红色叹号为必填项！");
							}
						}
						return false;
					}
				}
			} else {
				var divttt=document.createElement("div");
				divttt.innerHTML = tmpvalue;
				var tmpvaluettt = jQuery.trim(jQuery(divttt).text());
				if(tmpvaluettt == ""){
					if(thiswin.elements[i-1].getAttribute("temptitle")!=null && thiswin.elements[i-1].getAttribute("temptitle")!=""){
						if(window.__oriAlert__){
							window.top.Dialog.alert("\";"+thiswin.elements[i-1].getAttribute("temptitle")+"\""+"未填写");
						}else{
							var tempElement = thiswin.elements[i-1];
							
							//ueditor必填验证
							if (checkueditorContent(tempElement)) {
								continue;
							}
							
							window.top.Dialog.alert("&quot;"+thiswin.elements[i-1].getAttribute("temptitle")+"&quot;"+"未填写", function () {
								formElementFocus(tempElement);
							});
							
						}
						return false;
					}else{
						if(window.__oriAlert__){
							window.top.Dialog.alert("必要信息不完整，红色叹号为必填项！");
						}else{
							window.top.Dialog.alert("必要信息不完整，红色叹号为必填项！");
						}
						return false;
					}
				}
			}
		}
	}
	var flag=getformtable();
	return flag;
	//return true;
};

// 获取表单字段内容
function getformtable(){
	var qymc=$('input[ecologyname="uf_EnterpriseInfo.qymc"]').val();
	var qyjc=$('input[ecologyname="uf_EnterpriseInfo.qyjc"]').val();
	var qyfr=$('input[ecologyname="uf_EnterpriseInfo.qyfr"]').val();
	var yddh=custrim($('input[ecologyname="uf_EnterpriseInfo.yddh"]').val());
	// window.top.Dialog.alert("qymc:"+qymc);
	// window.top.Dialog.alert("qyjc:"+qyjc);
	// window.top.Dialog.alert("qyfr:"+qyfr);
	// window.top.Dialog.alert("qydh:"+yddh);
	var result={};
	$.ajax({
		url:"/jsp/dongfeng/qyadd.jsp",
		async:false,
		data:{"qymc":qymc,"qyjc":qyjc,"qyfr":qyfr,"yddh":yddh},
		dataType:"json",
		success:function(data){
			console.info(data);
			result=data;
		}
	});
	if(result.code==0){
		$("#field9541").val(result.bmhx);
		$("#field9542").val(result.qyfrhx);
		return true;
	}else{
		window.top.Dialog.alert(result.msg);
		return false;
	}
	return false;
}

 
 /*---------------------------------------
  * 清除字符串两端空格，包含换行符、制表符
  *---------------------------------------*/
function custrim(value) { 
   if(value!=undefined)	{
  		return value.replace(/(^[\s\n\t]+|[\s\n\t]+$)/g, "");
	}else{
		return "";
	}
 }
  
</script>